package View;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import music.emotion.Asset;

public class CollectInfo extends javax.swing.JPanel {

    private static final String[] names = {
        "/icon/big_smile.png",
        "/icon/Cry.png",
        "/icon/haha.png",
        "/icon/Adore.png",
        "/icon/pudency.png",
        "/icon/go.png",
        "/icon/relax.png",
        "/icon/read-book.png",
        "/icon/rain.png",
        "/icon/sport.png",
        "/icon/Study.png",
        "/icon/coffe.png"
    };
    private Icon[] emos = {
        new ImageIcon(getClass().getResource(names[0])),
        new ImageIcon(getClass().getResource(names[1])),
        new ImageIcon(getClass().getResource(names[2])),
        new ImageIcon(getClass().getResource(names[3])),
        new ImageIcon(getClass().getResource(names[4])),
        new ImageIcon(getClass().getResource(names[5])),
        new ImageIcon(getClass().getResource(names[6])),
        new ImageIcon(getClass().getResource(names[7])),
        new ImageIcon(getClass().getResource(names[8])),
        new ImageIcon(getClass().getResource(names[9])),
        new ImageIcon(getClass().getResource(names[10])),
        new ImageIcon(getClass().getResource(names[11])),};
    private String[] emoListString;
    private String[] ageListString;

    public CollectInfo() {
        int countFact = Asset.actionFactsList.size();
        int countAge = Asset.ageFactsList.size();
        emoListString = new String[countFact];

        for (int i = 0; i < countFact; i++) {
            emoListString[i] = Asset.actionFactsList.get(i).content.toString();
        }
        ageListString = new String[151];
        for (int i = 0; i < 151; i++) {
            ageListString[i] = Integer.toString(i);
        }

        initComponents();
        setSize(512, 315);
        emoList.addItemListener(
                new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent ie) {
                if (ie.getStateChange() == ItemEvent.SELECTED) {
                    lblEmo.setIcon(emos[emoList.getSelectedIndex()]);
                }
            }
        });

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        emoList = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        age = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        name = new javax.swing.JTextField();
        lblEmo = new javax.swing.JLabel(emos[0]);

        setBackground(new java.awt.Color(241, 241, 241));
        setForeground(new java.awt.Color(94, 105, 109));
        setPreferredSize(new java.awt.Dimension(512, 315));
        setLayout(null);

        jLabel1.setFont(new java.awt.Font("Segoe UI Light", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(15, 51, 100));
        jLabel1.setText("Bạn đang cảm thấy...");
        add(jLabel1);
        jLabel1.setBounds(10, 33, 297, 32);

        emoList.setFont(new java.awt.Font("Segoe UI Light", 0, 13)); // NOI18N
        emoList.setForeground(new java.awt.Color(15, 51, 100));
        emoList.setModel(new javax.swing.DefaultComboBoxModel(emoListString));
        emoList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                emoListActionPerformed(evt);
            }
        });
        add(emoList);
        emoList.setBounds(10, 70, 204, 30);

        jLabel2.setFont(new java.awt.Font("Segoe UI Light", 1, 16)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(15, 51, 100));
        jLabel2.setText("Cho chúng tôi biết một số thông tin khác về bạn");
        add(jLabel2);
        jLabel2.setBounds(10, 150, 372, 22);

        jLabel3.setFont(new java.awt.Font("Segoe UI Light", 0, 12)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(15, 51, 100));
        jLabel3.setText("Tên bạn");
        add(jLabel3);
        jLabel3.setBounds(10, 202, 40, 16);

        age.setFont(new java.awt.Font("Segoe UI Light", 0, 12)); // NOI18N
        age.setForeground(new java.awt.Color(15, 51, 100));
        age.setModel(new javax.swing.DefaultComboBoxModel(ageListString));
        age.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ageActionPerformed(evt);
            }
        });
        add(age);
        age.setBounds(71, 239, 152, 22);
        add(jLabel4);
        jLabel4.setBounds(23, 280, 0, 0);

        jLabel5.setFont(new java.awt.Font("Segoe UI Light", 0, 12)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(15, 51, 100));
        jLabel5.setText("Độ tuổi");
        add(jLabel5);
        jLabel5.setBounds(10, 242, 37, 16);

        name.setFont(new java.awt.Font("Segoe UI Light", 0, 12)); // NOI18N
        name.setForeground(new java.awt.Color(15, 51, 100));
        name.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nameActionPerformed(evt);
            }
        });
        add(name);
        name.setBounds(71, 199, 152, 22);
        add(lblEmo);
        lblEmo.setBounds(250, 10, 128, 128);
    }// </editor-fold>//GEN-END:initComponents

    public String getEmo() {
        return emoList.getSelectedItem().toString();
    }

    public String getName() {
        return name.getSelectedText();
    }

    public String getAge() {
        return age.getSelectedItem().toString();
    }

    private void nameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nameActionPerformed

    private void ageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ageActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ageActionPerformed

    private void emoListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emoListActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_emoListActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox age;
    private javax.swing.JComboBox emoList;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel lblEmo;
    private javax.swing.JTextField name;
    // End of variables declaration//GEN-END:variables
}
